﻿@model List<DLULearningNetwork.ViewModels.AccomodationInfoViewModel>
@if (false)
{ 
    <script type="text/javascript" src="../../Scripts/jquery-1.5.1-vsdoc.js"></script>
}
<script type="text/javascript">
    function SubmitAccomodationInfo() {    
        $.post("/Profile/SavingAccomodationInfo", $("#accomodationInfoForm").serialize(), function (data) {
            $("#accomodationInfoForm").parent().html(data);
             $("button").button();
        });
        return false;
    }
    var total = @Model.Count;
    function AddAccomodationInfo() {
        $.get("/Profile/AddInfomation", { typeName: "AccomodationInfo", index: total }, function (data) {
            $(data).insertAfter($("#accomodationInfoForm").find(".line").last());
        }); 
        total++;
    }
    $("a[name=delete]").live('click',function(){
        $(this).parent().remove();
        total -=1;
    })
</script>
@using (Html.BeginForm("SavingAccomodationInfo", "Profile", FormMethod.Post, new { id = "accomodationInfoForm", Class = "myForm" }))
{
    <input type="hidden" value="@Model.Count()"/>
    for (int i = 0; i < Model.Count(); i++)
    {
    <div>
        <a name="delete" href="#" onclick="return false;" style="margin-right:100px;" class="close">
                    </a> 
        <div class="clear">
        </div>
        <div class="formRow">
            <div class="colLeft">
                Địa chỉ :</div>
            <div class="colRight">
                @Html.EditorFor(m => m[i].Address)
                @Html.ValidationMessageFor(m => m[i].Address)
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="formRow">
            <div class="colLeft">
                Quốc gia :</div>
            <div class="colRight">@Html.EditorFor(m => m[i].Nation)
                @Html.ValidationMessageFor(m => m[i].Nation)
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="formRow">
            <div class="colLeft">
                Tỉnh thành phố :</div>
            <div class="colRight">@Html.EditorFor(m => m[i].Province)
                @Html.ValidationMessageFor(m => m[i].Province)
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="formRow">
            <div class="colLeft">
                Thời gian :</div>
            <div class="colRight">
                @Html.DropDownListForMonth(i, "StartMonth", Model[i].StartMonth) @Html.DropDownListForYear(i, "StartYear", Model[i].StartYear)
                --
                @Html.DropDownListForMonth(i, "EndMonth", Model[i].EndMonth) @Html.DropDownListForYear(i, "EndYear", Model[i].EndYear)
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="line">
        </div>
    </div>
    }
    <div class="clear">
    </div>
    <div class="formRow">
        <button onclick="AddAccomodationInfo();return false;">
            Thêm thông tin</button>
        <button onclick="SubmitAccomodationInfo();return false;">
            Cập nhật</button>
    </div>
    
}
